# -*- coding: utf-8 -*-

__author__ = 'bilibili'

import types
import copy
from spot_excel_reader import spot_excel_reader
from spot_config import spot_config
from spot_excel_analyzer_base import spot_excel_analyzer_base

class spot_area_analyzer(spot_excel_analyzer_base):
    # FUNCTION: __init__(self, string)
    #   the constructor of the class spot_order_funnal_analyzer
    # ARGS:
    #   @config_name: json config file name
    def __init__(self, config_name):
        spot_excel_analyzer_base.__init__(self, config_name)

    def fetch_key(self, in_dict):
        return in_dict['THEATER'] + '~' + in_dict['AREA']

    def new_value(self, in_dict):
        attr_list = self.config.get_attr('config', 'sum_columns')
        tmp_dict = copy.deepcopy(in_dict)
        for i in attr_list:
            tmp_dict[i] = 0
        return tmp_dict

    def value_operation(self, key, in_dict):
        attr_list = self.config.get_attr('config', 'sum_columns')
        for i in attr_list:
            if in_dict[i] != '':
                self.res_dict[key][i] += float(in_dict[i])

    def post_build_operation(self):
        pass

    def customized_calculation(self, arg_list):
        pass

def test_spot_area_analyzer():
    analyzer = spot_area_analyzer('C:\\svn_repo\\SPOT\\trunk\\DashboardDataService\\resources\\ASL new.config.json')
    analyzer.build_whole_table()
    print analyzer.get_result_dict()

if __name__ == '__main__':
    test_spot_area_analyzer()